package reflect;

import java.lang.reflect.Constructor;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Person person = new Person("唐俊", 250);
        System.out.println(person);
        Class cls = Class.forName("reflect.Person");
        Constructor c = cls.getConstructor(String.class, int.class);
        Object obj = c.newInstance("zq", 18);
        System.out.println(obj);

        Constructor c2=cls.getConstructor(String.class);
        Object obj2=c2.newInstance("HH");
        System.out.println(obj2);

    }
}
